package com.xykj.mapper;
import com.xykj.common.entry.ChinaIndex;
import com.xykj.pojo.dto.ChinaIndexDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChinaIndexMapper {
    @Select("select " +
            "index_name as indexName" +
            ", latest_price as latestPrice " +
            ", change_amount AS changeAmount" +
            ",change_percent AS changePercent" +
            " from china_index ci where ci.is_deleted=0" +
            " limit #{pageNum},#{pageSize}")
    List<ChinaIndexDto> queryChinaIndex(int pageNum, int pageSize);
    @Select("select " +
            "count(1) " +
            " from china_index ci where ci.is_deleted=0")
    Integer queryChinaIndexCount();


    @Select("SELECT COUNT(*) FROM china_index")
    int countAll();

    // 批量插入
    void batchInsert(@Param("list") List<ChinaIndex> list);


    void batchDelete(@Param("ids") List<Long> ids);

    // 查询所有未删除记录的ID
    List<Long> selectExistingIds();
}
